package com.ddm.pay;


import android.content.Context;
import android.util.Log;
import android.webkit.JavascriptInterface;

import java.lang.ref.SoftReference;

/**
 * Created by Administrator on 2018/9/17.
 */

public class DDMWebViewJavascriptBridge {
    private SoftReference<Context> contextSoftReference;
    private GPH5PayShareListener gph5PayShareListener;

    public DDMWebViewJavascriptBridge(Context context, GPH5PayShareListener gph5PayShareListener) {
        contextSoftReference = new SoftReference<>(context);
        this.gph5PayShareListener = gph5PayShareListener;

    }

    @JavascriptInterface
    public void appPayFinished(String message) {
        Log.d("appPayFinished", message);
//        Toast.makeText(contextSoftReference.get(), message, Toast.LENGTH_SHORT).show();
        gph5PayShareListener.onPurchaseCompleted(message);
    }

    @JavascriptInterface
    public String getToken() {
        return "";
    }

    public void onDestroy() {
        contextSoftReference = null;
        gph5PayShareListener = null;
    }
}
